<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: zhang
  Date: 2019/12/6
  Time: 18:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <title>多客管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../static/lib/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="../../static/css/admin.css" media="all" />
    <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet">
    <style>
        .ms{position: absolute; bottom: 0;left: 0; width: 100%; height: 25px; text-align: center;
            filter:alpha(Opacity=80);-moz-opacity:0.8;opacity: 0.8;background: #000;color: white;}
    </style>
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 10px;">
    <legend>修改活动</legend>
</fieldset>
<form class="layui-form layui-form-pane" action="${path}/subscribe/add" method="post" id="form">
    <input type="hidden" name="id" id="id" value="${subscribe.id}">
    <div class="layui-row">
        <div class="layui-col-xs6">
            <div class="layui-form-item">
                <label class="layui-form-label">活动名称</label>
                <div class="layui-input-block">
                    <input type="text" name="name" id="name" value="${subscribe.name}" autocomplete="off" placeholder="" class="layui-input" lay-verify="required">
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-col-xs6">
            <div class="layui-form-item">
                <label class="layui-form-label">预约收费金额</label>
                <div class="layui-input-block">
                    <input type="text" name="subscribeMoney" id="subscribeMoney" value="${subscribe.subscribeMoney}" autocomplete="off" placeholder="" class="layui-input" lay-verify="number">
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-col-xs6">
            <div class="layui-form-item">
                <label class="layui-form-label">核销奖励金额</label>
                <div class="layui-input-block">
                    <input type="text" name="reward" id="reward" value="${subscribe.reward}" autocomplete="off" placeholder="" class="layui-input" lay-verify="number">
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-col-xs6">
            <div class="layui-form-item">
                <label class="layui-form-label">开始时间</label>
                <div class="layui-input-block">
                    <input type="text" name="start" id="start" value="${subscribe.start.substring(0,19)}" autocomplete="off" placeholder="请选择时间" class="layui-input" lay-verify="required">
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-col-xs6">
            <div class="layui-form-item">
                <label class="layui-form-label">结束时间</label>
                <div class="layui-input-block">
                    <input type="text" name="over" id="over" value="${subscribe.over.substring(0,19)}" autocomplete="off" placeholder="请选择时间" class="layui-input" lay-verify="required">
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-col-xs6">
            <div class="layui-form-item" style="height: 200px;">
                <label class="layui-form-label">活动封面图</label>
                <div class="layui-input-block">
                    <img src="${subscribe.pic}" id="url" data-name="shareImage" width="100%" height="190px">
                    <span class="ms" style="width: 100%;">替换活动封面图</span>
                    <input type="hidden" name="pic" id="pic" value="${subscribe.pic}">
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-col-xs6">
            <div class="layui-form-item" style="height: 200px;">
                <label class="layui-form-label">活动背景图</label>
                <div class="layui-input-block">
                    <img src="${subscribe.background}" id="backgroundImg" data-name="backgroundImg" width="100%" height="190px">
                    <span class="ms" style="width: 100%;">替换活动背景图</span>
                    <input type="hidden" name="background" id="background" value="${subscribe.background}">
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-col-xs6">
            <div class="layui-form-item" style="height: 200px;">
                <label class="layui-form-label">活动分享图</label>
                <div class="layui-input-block">
                    <img src="${subscribe.poster}" id="posterImg" data-name="posterImg" width="100%" height="190px">
                    <span class="ms" style="width: 100%;">替换活动分享图</span>
                    <input type="hidden" name="poster" id="poster" value="${subscribe.poster}">
                </div>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-block">
            <div class="layui-input-block">
                <input type="radio" name="status" value="2" title="上线" lay-verify="required" <c:if test="${subscribe.status==2}">checked="checked"</c:if>>
                <input type="radio" name="status" value="1" title="下线" lay-verify="required" <c:if test="${subscribe.status==1}">checked="checked"</c:if>>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-col-xs6">
            <div class="layui-form-item">
                <label class="layui-form-label">规则</label>
                <div class="layui-input-block">
                    <textarea rows="4" cols="50" placeholder="请输入内容" name="rule" style="height: 200px;width: 100%;margin-left: 10px;resize: none" id="rule">${subscribe.rule}</textarea>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button" class="layui-btn layui-btn-normal" lay-submit lay-filter="LAY-user-front-submit" id="LAY-user-front-submit" value="确认">
    </div>
</form>
</body>
<script src="../../static/lib/layui/layui.js"></script>
<script src="../../static/js/jquery.min.js"></script>
<script>
    layui.config({
        base: "../../static/js/"
    }).extend({
        index: 'index' //主入口模块
    }).use(["index", "form", "laydate", "upload"], function (){
        var form = layui.form;
        var laydate = layui.laydate;
        var upload = layui.upload;

        //监听指定开关
        form.on('switch(switchBox)', function(data){
            this.checked ? $("#status").val(1):$("#status").val(0);
        });

        //设定文件大小限制
        upload.render({
            elem: "img[data-name='shareImage']"
            ,url: '${path}/upload/upload'
            ,size: 2048 //限制文件大小，单位 KB
            ,data:{uploadUrl:'temp/'}
            ,done: function(data,index,upload){
                if(data.code!=0){
                    layer.alert(data.msg,{icon:2});
                    return false;
                }
                $(this.item[0]).attr("src",data.data);
                $("#pic").val(data.data);
            }
        });
        //设定文件大小限制
        upload.render({
            elem: "img[data-name='backgroundImg']"
            ,url: '${path}/upload/upload'
            ,size: 2048 //限制文件大小，单位 KB
            ,data:{uploadUrl:'temp/'}
            ,done: function(data,index,upload){
                if(data.code!=0){
                    layer.alert(data.msg,{icon:2});
                    return false;
                }
                $(this.item[0]).attr("src",data.data);
                $("#background").val(data.data);
            }
        });
        //设定文件大小限制
        upload.render({
            elem: "img[data-name='posterImg']"
            ,url: '${path}/upload/upload'
            ,size: 2048 //限制文件大小，单位 KB
            ,data:{uploadUrl:'temp/'}
            ,done: function(data,index,upload){
                if(data.code!=0){
                    layer.alert(data.msg,{icon:2});
                    return false;
                }
                $(this.item[0]).attr("src",data.data);
                $("#poster").val(data.data);
            }
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#start',
            trigger: 'click',
            type:'datetime'

        });

        //执行一个laydate实例
        laydate.render({
            elem: '#over',
            trigger: 'click',
            type:'datetime'
        });
    });
    function addButClose(index){
        $('#addBut').attr("onclick",layer.close(index));
    }
</script>
</html>
